package com.fare.taluo.application.impl.plane.income;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fare.taluo.application.plane.income.TaskPlfIncomeApplication;
import com.fare.taluo.core.domain.config.line.OccupRateEntity;
import com.fare.taluo.io.excel.ExcelImportException;
import com.fare.taluo.vo.income.plfIncomeVO;

@Scope
@Service
@Transactional
public class TaskPlfIncomeApplicationImpl implements TaskPlfIncomeApplication{
	
	public void importTasks(List<plfIncomeVO> incomes) throws ExcelImportException{		
		
		List<OccupRateEntity> templates = new ArrayList<OccupRateEntity>();
		plfIncomeVO pliVo = null;
		StringBuilder sbuilder = new StringBuilder();
		if(incomes != null && !incomes.isEmpty()){
			
			for(plfIncomeVO vo:incomes){
//				OccupRateEntity entity = new OccupRateEntity(pliVo.getCompanyCode(),pliVo.getLineCode(),
//						pliVo.getFlightInfo(),pliVo.getFlightDay(),pliVo.getPrice(),pliVo.getOccupRate(),pliVo.getIncome());
				
				OccupRateEntity entity = new OccupRateEntity();				
				entity.setCompanyCode(vo.getCompanyCode());
				entity.setLineCode(vo.getLineCode());
				entity.setFlightInfo(vo.getFlightInfo());
				entity.setFlightDay(vo.getFlightDay());
				entity.setPrice(vo.getPrice());
				entity.setOccupRate(vo.getOccupRate());
				entity.setIncome(vo.getIncome());
				templates.add(entity);
			}
			
		}
		if(!templates.isEmpty()){
			
			for(OccupRateEntity e:templates){
				e.saveOrUpdateOccupRateEntity();
			}
			
		}
		
		
	}

}
